# !/usr/bin/env python
# -*-coding:utf-8 -*-
# python -m pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade pip

"""
请在此模块配置UI信息
"""

from common.config_ini import Config


class UISettings:

    def __init__(self):
        # 显示信息设置
        self.AppDes = '欢迎使用 Mr丨Deer 办公辅助系统, 祝您使用愉快...'  # 标题栏描述

        # 大小尺寸设置
        self.app_min_width = 900  # 软件最小宽度
        self.app_min_height = 600  # 软件最小高度
        self.menu_min_width = 60  # 菜单栏最小宽度
        self.menu_max_width = 200  # 菜单栏最大宽度
        self.animation_time = 400  # 动画时长

        # 根据主题改变按钮图标
        self.btn_min = ''
        self.btn_max = ''
        self.btn_restore = ''
        self.btn_close = ''
        self.btn_settings = ''
        self.btn_switch_theme = ''
        self.btn_switch_menu = ''
        self.btn_switch_open = ''
        self.btn_switch_close = ''
        self.btn_home = ''

        # ini配置文件
        self.config = Config('conf/app_config.ini')
        self.theme = None

    # 获取QSS样式
    def get_qss(self):
        self.theme = self.config.get('App', 'theme')

        if self.theme == 'dark':
            self.btn_min = ":/icons/pictures/icons/最小化_.png"
            self.btn_max = ":/icons/pictures/icons/最大化_.png"
            self.btn_restore = ":/icons/pictures/icons/还原_.png"
            self.btn_close = ":/icons/pictures/icons/关闭_.png"
            self.btn_switch_theme = ":/icons/pictures/icons/开关-开.png"
            self.btn_switch_open = ':/icons/pictures/icons/展开_.png'
            self.btn_switch_close = ':/icons/pictures/icons/收起_.png'
            self.btn_home = ':/icons/pictures/icons/home_.png'
            self.btn_settings = ':/icons/pictures/icons/设置_.png'
        else:
            self.btn_min = ":/icons/pictures/icons/最小化.png"
            self.btn_max = ":/icons/pictures/icons/最大化.png"
            self.btn_restore = ":/icons/pictures/icons/还原.png"
            self.btn_close = ":/icons/pictures/icons/关闭.png"
            self.btn_switch_theme = ":/icons/pictures/icons/开关-关.png"
            self.btn_switch_open = ':/icons/pictures/icons/展开.png'
            self.btn_switch_close = ':/icons/pictures/icons/收起.png'
            self.btn_home = ':/icons/pictures/icons/home.png'
            self.btn_settings = ':/icons/pictures/icons/设置.png'
        # 加载QSS文件
        with open(f'ui/qtui/themes/{self.theme}.qss', 'r', encoding='utf-8') as f:
            qss_style = f.read()
        return qss_style


GUISet = UISettings()
